<#import "/macro.ftl" as m>
<@m.page_header title='后台' />
<div id="page-content-wrapper">

<div id="page-title">

    <h3>
        <#if medium>修改媒体报道<#else>添加媒体报道</#if>
    </h3>
 
</div>
<div class="pad10A">
<#if medium> 
<form id="demo-form1" action="/medium/mediumupdate/${medium.id}" class="col-md-12" method="POST">
<#else>
<form id="demo-form1" action="/medium/mediumadd" class="col-md-12" method="POST">
</#if>

	<#if medium>
	<input type="hidden" name="id" value="${medium.id}"/>
	</#if>
   <div class="form-row">
        <div class="form-label col-md-2">
            <label for="">
                标题:
                <span class="required">*</span>
            </label>
        </div>
        <div class="form-input col-md-8">
            <input type="text" id="title" name="title" data-trigger="change" data-required="true" class="parsley-validated" value="${medium.title}">
        </div>
    </div>
    
    <div class="form-row">
	    <div class="form-label col-md-2">
	        <label for="">
	            报道时间:
	            <span class="required">*</span>
	        </label>
	    </div>
	    <div class="form-input col-md-2">
	        <input type="text" name="reportDate" data-trigger="focus" data-required="true" class="parsley-validated"
	               value="${(medium.reportDate?string("yyyy-MM-dd HH:mm:ss"))!}"
	               onClick="WdatePicker({isShowWeek:true,dateFmt:'yyyy-MM-dd HH:mm:ss'})"
	               style="clear:both;overflow:hidden;display:block">
	    </div>
	</div>
    
    <div class="form-row">
        <div class="form-label col-md-2">
            <label for="">
                媒体来源:
                <span class="required">*</span>
            </label>
        </div>
        <div class="form-input col-md-5">
            <select name="institutionId">
            <#list miList as institution>
        		<option value="${institution.id}" <#if medium.institution.id == '${institution.id}'>selected</#if>>${institution.medium}</option>
        	</#list>
        	</select>
        </div>
    </div>
    
    <div class="form-row">
        <div class="form-label col-md-2">
            <label for="">
                来源URL:
            </label>
        </div>
        <div class="form-input col-md-8">
            <input type="text" id="sourceUrl" name="sourceUrl" data-trigger="change" value="${medium.sourceUrl}">
        </div>
    </div>
    
    <div class="form-row">
        <div class="form-label col-md-2">
            <label for="">
                图片URL:
                <span class="required">*</span>
            </label>
        </div>
        <div class="form-input col-md-8">
            <input type="text" id="pictureUrl" name="pictureUrl" data-trigger="change" data-required="true" class="parsley-validated" value="${medium.pictureUrl}">
        </div>
    </div>
    
    <div class="form-row">
        <div class="form-label col-md-2">
            <label for="">
                简介:
                <span class="required">*</span>
            </label>
        </div>
        <div class="form-input col-md-8">
            <textarea id="introduction" name="introduction" data-trigger="change" class="parsley-validated" value="">${medium.introduction}</textarea>
        </div>
    </div>
    
	<div class="form-row">
        <div class="form-label col-md-2">
            <label for="">
                内容:
                <span class="required">*</span>
            </label>
        </div>
        <div class="form-input col-md-3">
		 	<textarea id="editor" name="content" style="width:600px;height:400px;">${(medium.content)!}</textarea>
        </div>
    </div>
    
    <div class="form-row">
        <div class="form-label col-md-2">
            <label for="">
                是否置顶:
                <span class="required">*</span>
            </label>
        </div>
        <div class="form-input col-md-2">
            <select name="top">
        		<option value="top" <#if medium.top == 'top'>selected</#if>>是</option>
        		<option value="down" <#if medium.top == 'down'>selected</#if>>否</option>
        	</select>
        </div>
    </div>
    <div class="form-row">
        <div class="form-label col-md-2">
            <label for="">
                是否发布:
                <span class="required">*</span>
            </label>
        </div>
        <div class="form-input col-md-2">
            <select name="publish">
        		<option value="1" <#if medium.publish>selected</#if>>是</option>
        		<option value="0" <#if !medium.publish>selected</#if>>否</option>
        	</select>
        </div>
    </div>
    
    <div class="divider"></div>
    <div class="form-row">
        <input type="hidden" name="superhidden" id="superhidden">
       <div class="form-input col-md-10 col-md-offset-2">
                    <a href="javascript:;" class="btn medium primary-bg radius-all-4 col-md-2" id="demo-form-2-valid">提交</a>
        </div>
    </div>   

</form>
</div>
</div>


<script type="text/javascript" src="/assets/ueditor/ueditor.config.js"></script>
<script type="text/javascript" src="/assets/ueditor/ueditor.all.js"></script>
<script type="text/javascript" src="/assets/ueditor/lang/zh-cn/zh-cn.js"></script>
<script type="text/javascript">

<#if medium!=null>
	var uySaveFloder ="medium/${medium.id}";
</#if>
<#if medium==null>
	var uySaveFloder ="medium/"+new Date().getFullYear()+""+new Date().getMonth()+""+new Date().getDate();
</#if>

$(function(){
	var ue = UE.getEditor('editor', {upYunSaveFolder: uySaveFloder});
    ue.options.allowDivTransToP = false;
    
	$("#demo-form-2-valid").click(function(){
		$('#demo-form1').parsley('validate');
	    $('#demo-form1').trigger('submit');
	});
});

</script>